package my.iterator;

import lombok.Data;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

//煎饼屋菜单实现
@Data
public class PancakeHouseMenu implements Menu {
    private List<MenuItem> menuItems;

    public PancakeHouseMenu() {
        menuItems = new ArrayList<>();
        addItem("玉米煎饼", "德美亚玉米", true, 2.99);

        addItem("虾仁煎饼", "舟山虾仁", false, 10);

        addItem("山东煎饼", "山东白面", true, 2.7);

    }

    public void addItem(String name, String description, boolean vegetarian, double price) {
        MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
        menuItems.add(menuItem);
    }

    //因为 jdk list 自身携带了  Iterator 所以不需要创建 自定义的迭代器了
    @Override
    public Iterator createIterator() {
        return menuItems.iterator();
    }
}
